package pack;

import java.io.File;

public class ShowDirectoryAndSize
{	
	public ShowDirectoryAndSize(String path)
	{
		File root = new File(path);
		printDirectory(root.getPath(), 0);
	}
	
	public long printDirectory(String path, int level)
	{
		long sizeByte = 0;
		
		File tmp = new File(path);
		for(int k = 0; k < level; k++)
			System.out.print("\t");
		System.out.println(tmp.getPath());
		
		File[] files = tmp.listFiles();
		for(int k = 0; k < files.length; k++)
			if(files[k].isDirectory())
				 sizeByte += printDirectory(files[k].getPath(), level+1);
			else
				sizeByte += files[k].length();

		for(int k = 0; k < level; k++)
			System.out.print("\t");
		System.out.println("Size: " + sizeByte);
		
		return sizeByte;
	}
	
	public static void main(String[] args)
	{
		ShowDirectoryAndSize a = new ShowDirectoryAndSize("..");
	}
}
